<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;
use App\Model\UserWalletModel;



//后台模块表
class ShopOrderFstModel extends Model
{
    //定义一个表名
    protected $table = 'shop_order_fst';
    //定义主键
    protected $primaryKey = 'id';

    //生成记录
    /*
     * fid 子订单id
     * sku_id  sku_id
     * gid   商品id
     * attr_name 规格属性
     * sid  仓库id
     * num  数量
     * cost_price 成本价
     * sell_price 销售价
     * total 总价
     * good_pic 商品图片
     * good_name 商品名
     *
     */
    public static function add($fid,$gid,$sid,$num,$cost_price,$sell_price,$total,$good_pic,$good_name,$sku_id,$attr_name)
    {

        $shoporderfst = new ShopOrderFstModel();
        if($sku_id == 0 && $attr_name == 0){
            $shoporderfst->fid = $fid;
            $shoporderfst->gid = $gid;
            $shoporderfst->sid = $sid;
            $shoporderfst->num = $num;
            $shoporderfst->cost_price = $cost_price;
            $shoporderfst->sell_price = $sell_price;
            $shoporderfst->total = $total;
            $shoporderfst->good_pic = $good_pic;
            $shoporderfst->good_name = $good_name;
        }else{
            $shoporderfst->fid = $fid;
            $shoporderfst->sku_id = $sku_id;
            $shoporderfst->gid = $gid;
            $shoporderfst->attr_name = $attr_name;
            $shoporderfst->sid = $sid;
            $shoporderfst->num = $num;
            $shoporderfst->cost_price = $cost_price;
            $shoporderfst->sell_price = $sell_price;
            $shoporderfst->total = $total;
            $shoporderfst->good_pic = $good_pic;
            $shoporderfst->good_name = $good_name;
        }

        $shoporderfst->save();



    }

}
